﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="IntellisenseControl.ascx.cs" Inherits="Basic4Net.OAWeb.CustomControl.IntellisenseControl" %>
<script type="text/javascript">
	function <%= this.ClientID %>_InitIntellisense() {
		var type = "<%= IntellisenseType %>";
		$("#<%= this.txtIntellisense.ClientID %>").suggest('<%=Page.ResolveClientUrl("~/Suggest") %>/IntellisenseHandler.ashx?act=<%= this.txtIntellisense.ClientID %>&Type=' + type, {
			onSelect: function () {
				var result = this.value.toString();
				var index = result.lastIndexOf('_');
				var id = result.substr(index + 1);
				var res = result.substr(0, index);
				$("#<%= this.txtIntellisense.ClientID %>").val(res);
				$("#<%= this.txtIntellisense_ID.ClientID %>").val(id);
			}
		});
	}
	function <%= this.ClientID %>_InitIntellisense_Amount(targetId) {
		var type = "<%= IntellisenseType %>";
		$("#<%= this.txtIntellisense.ClientID %>").suggest('<%=Page.ResolveClientUrl("~/Suggest") %>/IntellisenseHandler.ashx?act=<%= this.txtIntellisense.ClientID %>&Type=' + type, {
			onSelect: function () {
				var result = this.value.toString();
				var index = result.lastIndexOf('_');
				var amount = result.substr(index + 1);



				result = result.substr(0, index);
				index = result.lastIndexOf('_');
				var id = result.substr(index + 1);
				var res = result.substr(0, index);

				
				$("#<%= this.txtIntellisense.ClientID %>").val(res);
				$("#<%= this.txtIntellisense_ID.ClientID %>").val(id);
				$("#"+targetId).val(amount);
			}
		});
	}
</script>

<asp:TextBox MaxLength="20" ID="txtIntellisense" runat="server" CssClass="txtStyle" Style="width: 90%;"></asp:TextBox>
<asp:TextBox MaxLength="20" ID="txtIntellisense_ID" runat="server" CssClass="txtStyle" style="display:none;"></asp:TextBox>
